package com.lst.api.controller;

import com.lst.api.entity.OrderContract;
import com.lst.api.service.IOrderContractService;
import com.lst.api.vo.OrderContractVo;
import com.lst.tools.custom.annotation.TokenPermission;
import com.lst.tools.custom.context.BaseContextHandler;
import com.lst.tools.custom.vo.JsonResponse;
import com.lst.tools.web.annotation.WebLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 订单合同控制层
 *
 * @author xibiao
 * @date 2020-02-09
 * @version: V1.0
 */
@Api(tags = "订单合同表控制层")
@RestController
@RequestMapping(value = "/orderContract")
public class OrderContractController {
	
	@Autowired
    private IOrderContractService orderContractService;
    
    @ApiOperation(value = "保存订单、合同信息，并生成合同预览文件")
    @PostMapping(value = "/save", headers = "content-type=multipart/form-data")
    @TokenPermission   
    @WebLog
    public JsonResponse<OrderContract> saveOrderContract(@RequestParam("file") MultipartFile signFile,
                                                         OrderContractVo ocVo) throws Exception {
    	long userId = BaseContextHandler.getUserId();
    	OrderContract orderContract = orderContractService.saveOrderContract(signFile, ocVo, userId);
    	return JsonResponse.success(orderContract);
    }
    
    
}